Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: first pass at html output #88

Merged
merged 2 commits into from
Oct 24, 2023
Merged

ENH: first pass at html output #88

merged 2 commits into from
Oct 24, 2023

Conversation

klauer
Copy link
Owner

@klauer klauer commented Oct 24, 2023

(This is part of a larger branch which got to be unmanageably large - breaking it up into separate PRs)

A first pass at allowing blark to output syntax-highlighted (or HTML entity-annotated) code. I anticipated using this in documentation at some point, rather than writing something for Pygments

Things to do, maybe or maybe not in this PR:

  • Remove the hardcoded stylesheet in the output
  • Add test suite case for this output (done, in a smoke tested way)
  • Other things I'm forgetting here (done, because I haven't recalled what these were)

A couple interesting notes:

  • Stylesheet-wise: if I can make a decent looking theme for the output, I may consider adding some sample CSS as part of the package (but not in each output).
  • This currently only works to syntax highlight (well, add tags with defined HTML classes - the coloring is up to you) the original code. That is to say, it won't reformat the output and then syntax highlight it. blark can't correlate its output (post-generation) to its input (the raw source code), so it'd actually require a few steps to do this. Parse code -> reformat it -> re-parse the formatted code -> add HTML annotations there.
  • Anyone with an interest - suggestions are welcome as per usual. Consider this a WIP of a preliminary feature at best

Sound like a couple problems for another day...

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2023

Codecov Report

Merging #88 (4cd1d06) into master (a39b3f1) will increase coverage by 0.4%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #88     +/-   ##
========================================
+ Coverage    81.1%   81.5%   +0.4%     
========================================
  Files          26      27      +1     
  Lines        5743    5819     +76     
========================================
+ Hits         4662    4747     +85     
+ Misses       1081    1072      -9     
Files Coverage Δ
blark/__init__.py 100.0% <100.0%> (ø)
blark/html.py 100.0% <100.0%> (ø)
blark/tests/test_cli.py 91.5% <ø> (ø)

... and 1 file with indirect coverage changes

@klauer klauer merged commit abce326 into master Oct 24, 2023
24 checks passed
@klauer klauer deleted the html_output branch October 24, 2023 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants